﻿using Dou;
using Dou.Resource;
using UnityEngine;

namespace Simple
{
    public class Test_GameMain : AbstractGameMain
    {
        private static Test_GameMain _instance;

        public static Test_GameMain instance => _instance;

        protected override void Awake()
        {
            base.Awake();
        }
        
#if UNITY_EDITOR
        
        protected override void OnEditorInit()
        {
            base.OnEditorInit();
        }
        
#endif

        protected override void OnInit()
        {
            _instance = this;

            // SimpleLoadTest(); // 最基础的资源加载测试
            SpriteLoadTest(); // 图集资源加载测试
        }

        private void SimpleLoadTest()
        {
            var root = GameObject.Find("Canvas");
            
            AssetManager.instance.LoadPrefab("TestUI", obj =>
            {
                var go = obj as GameObject;
                go.transform.SetParent(root.transform);
                var rect = go.GetComponent<RectTransform>();
                rect.anchoredPosition = Vector2.zero;
            });
        }

        private void SpriteLoadTest()
        {
            var root = GameObject.Find("Canvas");
            
            AssetManager.instance.LoadPrefab("SpriteUI", obj =>
            {
                var go = obj as GameObject;
                go.transform.SetParent(root.transform);
                var rect = go.GetComponent<RectTransform>();
                rect.anchoredPosition = Vector2.zero;
            });
        }

        protected override void Start()
        {
            base.Start();
        }

        protected override void FixedUpdate()
        {
            base.FixedUpdate();
        }

        protected override void Update()
        {
            base.Update();
        }

        protected override void LateUpdate()
        {
            base.LateUpdate();
        }

        protected override void OnApplicationPause(bool pause)
        {
            base.OnApplicationPause(pause);
        }

        protected override void OnApplicationFocus(bool focus)
        {
            base.OnApplicationFocus(focus);
        }

        protected override void OnApplicationQuit()
        {
            base.OnApplicationQuit();
        }
    }
}
